﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Pakxel.Data;
using Telerik.WinControls.UI;

namespace Pakxel.SmartLogistic.Admon
{
    public partial class DetalleCxCWorkBench : Telerik.WinControls.UI.RadForm
    {
        private MEDataDataContext DataContext;
        private void SetUpDetalleGridView()
        {
            cxcDetalleGridView.AllowEditRow = false;
            cxcDetalleGridView.AllowAddNewRow = false;
            cxcDetalleGridView.AllowDeleteRow = false;
            cxcDetalleGridView.AutoGenerateColumns = true;

            //GridViewDateTimeColumn colT030Fecha = new GridViewDateTimeColumn("T026FechaIngreso", "T026FechaIngreso");
            //colT030Fecha.HeaderText = "Fecha";
            //colT030Fecha.FormatInfo = new System.Globalization.CultureInfo("es-MX");
            //colT030Fecha.FormatString = "{0:dd/MM/yyyy}";
            //colT030Fecha.Width = 400;

            //GridViewDecimalColumn colT030Anticipo = new GridViewDecimalColumn("T030Anticipo", "T030Anticipo");
            //colT030Anticipo.HeaderText = "Monto";
            //colT030Anticipo.FormatInfo = new System.Globalization.CultureInfo("es-MX");
            //colT030Anticipo.FormatString = "{0:C}";
            //colT030Anticipo.Width = 400;

            //try
            //{
            //   //cxpDetalleGridView.Columns.Add(colT030Fecha);
            //   //cxpDetalleGridView.Columns.Add(colT030Anticipo);

            //}
            //catch (SystemException se)
            //{
            //   MainApp.WriteExceptionToLog(se);
            //}
        }
        public DetalleCxCWorkBench()
        {
            InitializeComponent();
        }

        private void DetalleCxCWorkBench_Load(object sender, EventArgs e)
        {
            DataContext = new MEDataDataContext(WorkBench.ConnectionString);
            SetUpDetalleGridView();
            cxcDetalleGridView.DataSource = DataContext.GetFacturacionCxC();
            foreach (GridViewDataColumn col in this.cxcDetalleGridView.Columns)
            {
                col.BestFit();
            }
        }

        private void tsbActualizar_Click(object sender, EventArgs e)
        {
           cxcDetalleGridView.DataSource = DataContext.GetFacturacionCxC();
           foreach (GridViewDataColumn col in this.cxcDetalleGridView.Columns)
           {
              col.BestFit();
           }
        }

        private void tsbVencidas_Click(object sender, EventArgs e)
        {
           cxcDetalleGridView.DataSource = DataContext.GetFacturasVencidasCxC();
           foreach (GridViewDataColumn col in this.cxcDetalleGridView.Columns)
           {
              col.BestFit();
           }
        }
    }
}
